package com.mapResult.domain;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

@Mapper
public interface PersonMapStruct {
    public static final PersonMapStruct INSTANCE = Mappers.getMapper(PersonMapStruct.class);

    @Mapping(expression = "java( com.alibaba.fastjson.JSON.toJSONString(personVO.getInfo() , com.alibaba.fastjson.serializer.SerializerFeature.WriteMapNullValue) )",target = "info")
    @Mapping(expression = "java( com.alibaba.fastjson.JSON.toJSONString(personVO.getTest() , com.alibaba.fastjson.serializer.SerializerFeature.WriteMapNullValue) )",target = "test")
    PersonDTO Vo2Dto(PersonVO personVO);

    @Mapping(expression = "java( com.alibaba.fastjson.JSON.parseObject(personDTO.getInfo(), java.util.HashMap.class) )",target = "info")
    @Mapping(expression = "java( com.alibaba.fastjson.JSON.parseObject(personDTO.getTest(), java.util.HashMap.class) )",target = "test")
    PersonVO Dto2Vo(PersonDTO personDTO);

}
